<template>
  <view>
    <view class="reservation_content">
      <leeLoading :animateTxt="leeLoading.animateTxt" :type="leeLoading.type" :shadowBg="leeLoading.shadowBg"
        :show="leeLoading.show"></leeLoading>
      <view class="header_title">
        <view class="automatic">
          醒发预约
        </view>
      </view>

      <view class="parameter_seting">
        <view class="parameter_name">
          <image src="https://mkservice.mk-iot.com/subFile/mk2240/rectangle.png" class="rectangleimg" />
          <view class="parameter_title">
            参数设置
          </view>
        </view>
        <view class="control_btn">
          <view class="tabs" v-for="(item,index) in parameterData" :key="index" @tap="navSwitch(item.id)"
            :style="item.id==navState?'background-color:#0089F9':''">
            <image :src="item.imgurl" class="tab_img" />
            <view class="freezing_text" :style="item.id==navState?'color:#fff':''">
              {{item.name}}
            </view>
          </view>
        </view>
        <weekbutton :weekReservation="indexAllData.weekReservation" :equipmentNo="equipmentNo"
          :equipmentTypeId="equipmentTypeId"></weekbutton>
        <scroll-view class="scroll-list" scroll-y="true" :style="'height:' +clientHeight+'px;'">
        <view class="tab_content">
          <view v-if="navState==0" class="freezing_content">
            <view class="temp_set">
              <image src="https://mkservice.mk-iot.com/subFile/mk2240/rectangle.png" class="rectangleimg" />
              <view class="parameter_title">
                温度设置
              </view>
            </view>
            <view class="tempclass">
              <tempsilder :currentValue="autoCurveDataPak.freeTemp" :min="LTp" :max="HTp" :currState="1"></tempsilder>
            </view>
          </view>
          <view v-if="navState==1" class="refrigerate_content">
            <view class="selectTime">
              <view class="start_time">
                <image src="https://mkservice.mk-iot.com/subFile/mk2240/start_icon.png" />
                <view class="startTimetext">起始时间</view>
              </view>
              <picker mode="time" :value="chiT" start="00:00" end="23:59" @change="bindRefrigerateSTime">
                <view class="uni-input">
                  {{chiT}}
                </view>
              </picker>
            </view>
            <view class="temp_set">
              <image src="https://mkservice.mk-iot.com/subFile/mk2240/rectangle.png" class="rectangleimg" />
              <view class="parameter_title">
                温度设置
              </view>
            </view>

            <view class="tempclass">
              <tempsilder :currentValue="autoCurveDataPak.storageTemp" :min="LTp" :max="HTp" :currState="2">
              </tempsilder>
            </view>
          </view>
          <view v-if="navState==2" class="proofingone_content" style="margin-top: 20rpx;">
            <view class="selectTime">
              <view class="start_time">
                <image src="https://mkservice.mk-iot.com/subFile/mk2240/start_icon.png" />
                <view class="startTimetext">起始时间</view>
              </view>
              <picker mode="time" :value="prf1T" start="00:00" end="23:59" @change="bindXf1STime">
                <view class="uni-input">{{prf1T}}</view>
              </picker>
            </view>
            <view class="temp_set">
              <image src="https://mkservice.mk-iot.com/subFile/mk2240/rectangle.png" class="rectangleimg" />
              <view class="parameter_title">
                温度设置
              </view>
            </view>
            <view class="tempclass">
              <tempsilder :currentValue="autoCurveDataPak.xf1Temp" :min="ProLTp" :max="ProHTp" :currState="3">
              </tempsilder>
            </view>
            <view class="humidity_set" style="display: flex;align-items: center;margin-top: 40rpx;">
              <image src="https://mkservice.mk-iot.com/subFile/mk2240/rectangle.png" class="rectangleimg" />
              <view class="parameter_title">
                湿度设置
              </view>
            </view>
            <view class="tempclass">
              <humiditysilder :currentValue="autoCurveDataPak.xf1Humidity" :min="0" :max="100" :currState="1">
              </humiditysilder>
            </view>
          </view>
          <view v-if="navState==3" class="proofingtwo_content" style="margin-top: 40rpx;">
            <view class="selectTime">
              <view class="start_time">
                <image src="https://mkservice.mk-iot.com/subFile/mk2240/start_icon.png" />
                <view class="startTimetext">起始时间</view>
              </view>
              <view>---</view>
              <view class="start_time">
                <image src="https://mkservice.mk-iot.com/subFile/mk2240/start_icon.png" />
                <view class="startTimetext">结束时间</view>
              </view>
            </view>
            <view class="start_endtime">
              <view class="stime">
                <picker mode="time" :value="prf2ST" start="00:00" end="23:59" @change="bindXf2STime">
                  <view class="uni-input">{{prf2ST}}</view>
                </picker>
              </view>
              <view class="etime">
                <picker mode="time" :value="prf2ET" start="00:00" end="23:59" @change="bindXf2ETime">
                  <view class="uni-input">{{prf2ET}}</view>
                </picker>
              </view>
            </view>

            <view class="temp_set">
              <image src="https://mkservice.mk-iot.com/subFile/mk2240/rectangle.png" class="rectangleimg" />
              <view class="parameter_title">
                温度设置
              </view>
            </view>
            <view class="tempclass">
              <tempsilder :currentValue="autoCurveDataPak.xf2Temp" :min="ProLTp" :max="ProHTp" :currState="4">
              </tempsilder>
            </view>
            <view class="humidity_set" style="display: flex;align-items: center;margin-top: 40rpx;">
              <image src="https://mkservice.mk-iot.com/subFile/mk2240/rectangle.png" class="rectangleimg" />
              <view class="parameter_title">
                湿度设置
              </view>
            </view>
            <view class="tempclass">
              <humiditysilder :currentValue="autoCurveDataPak.xf2Humidity" :min="0" :max="100" :currState="2">
              </humiditysilder>
            </view>
          </view>
        </view>
       </scroll-view>
      </view>
    </view>
    <navtabar :selected="index"></navtabar>
  </view>
</template>

<script>
  const CLOSE = 0;
  const CmdType = {
    DeviceTime: 10,
    AutoCurve: 11
  }
  import navtabar from '../components/proofing-tabbar/index.vue';
  import weekbutton from '../components/week-button/index.vue';
  import tempsilder from '../components/temp-silder/index.vue';
  import humiditysilder from '../components/humidity-silder/index.vue';
  import dataconver from '../util/data_conversion'
  import {
    toast
  } from '../../utils/common';
  import parsingData from '../util/parsingData'
  import {
    MQTT_IP,
    MQTT_OPTIONS
  } from '@/utils/mqtt.js';
  import getdateTime from '../../utils/getdateTime';
  var Paho = require("../../utils/paho-mqtt");
  import getPrefixAndControl from '../util/getPrefixAndControl'
  import leeLoading from '../components/StarLee-loading/leeLoading.vue';
  export default {
    components: {
      navtabar,
      weekbutton,
      tempsilder,
      humiditysilder,
      leeLoading
    },
    data() {
      return {
        clientHeight: 0,
        leeLoading: {
          show: false,
          type: 'rotate3',
          shadowBg: '',
          animateTxt: true
        },
        refrigerateSTime: '00:00',
        xf1STime: '00:00',
        xf2STime: '00:00',
        xf2ETime: '00:00',
        chiT: '00:00',
        prf1T: '00:00',
        prf2ST: '00:00',
        prf2ET: '00:00',
        realTime: null,
        timers: null,
        timeout: null,
        isRendering: false, //是否下发时
        index: 1,
        navState: 0, //导航状态
        parameterData: [{
          id: 0,
          imgurl: 'https://mkservice.mk-iot.com/subFile/mk2240/freezing_click.png',
          name: '冷冻'
        }, {
          id: 1,
          imgurl: 'https://mkservice.mk-iot.com/subFile/mk2240/refrigerate_onclick.png',
          name: '冷藏'
        }, {
          id: 2,
          imgurl: 'https://mkservice.mk-iot.com/subFile/mk2240/proofingone_onclick.png',
          name: '醒发1'
        }, {
          id: 3,
          imgurl: 'https://mkservice.mk-iot.com/subFile/mk2240/proofingtwo_onclick.png',
          name: '醒发2'
        }],
        subTopic: uni.getStorageSync("subTopic"),
        equipmentNo: uni.getStorageSync("equipmentNo"), // uni.getStorageSync("equipmentNo"),
        equipmentTypeId: uni.getStorageSync("equipmentTypeId"), // uni.getStorageSync("equipmentTypeId"),
        indexAllData: '',
        autoCurveDataPak: '',
        setData: '',
        HTp: 60, //温度最大值
        LTp: -20, //温度最小值
        ProHTp: 60, //醒发温度最大值
        ProLTp: 5, //醒发温度最大值
        show: false,
        etimeShow: false,
        client: null
      }
    },
    onLoad() {
      var that = this;
      uni.getSystemInfo({
          success: function(res) {
            let screenHeight = uni.getSystemInfoSync().windowHeight //获取屏幕高度
            // 通过query 获取其余盒子的高度
            let query = uni.createSelectorQuery().in(that)
              query.select(".header_title").boundingClientRect()
              query.select(".parameter_seting").boundingClientRect()
              query.select(".control_btn").boundingClientRect()
            //通过query.exec返回的数组 进行减法 同时 去除margin 和border的
            query.exec(res => {
              let h1 = res[0].height
              let h2 = res[1].height
              let h3 = res[2].height
              let scrollHeight = screenHeight - h1 - h2 -60
              that.clientHeight = scrollHeight
            })
          }
        })
      uni.showLoading({
        title: "数据加载中...",
        mask: true
      })
      //延迟一秒钟去获取数据
      this.getIndexData()
      setTimeout(async () => {
        //链接mqtt
        this.connect()
      }, 1000);
      //15秒后没关闭就自动关闭
      this.timers = setTimeout(() => {
        uni.hideLoading();
      }, 15000);
    },
    // 组件销毁时关闭定时器
    beforeDestroy() {
      clearTimeout(this.timers)
    },
    methods: {
      getIndexData() {
        this.realTime = setInterval(async () => {
          //下发0x0f获取预约0x07周期
          //进入界面链接mqtt后自动订阅
          const success = await getPrefixAndControl.getConfigList(this.equipmentTypeId, this.equipmentNo, CmdType
            .DeviceTime)
          if (success.code != 200) {
            this.$modal.msgError("下发失败");
          }
        }, 2000);
      },
      connect() {
        try {
          const thant = this
          this.client = new Paho.Client(MQTT_IP, "SERVER_" + Math.floor(Math.random() * 999) + 1 + "_" + thant
            .equipmentNo);
          //后面这个字符串可以用一个随机字符串方法随机生成
          var connectOptions = {
            timeout: MQTT_OPTIONS.timeout,
            useSSL: MQTT_OPTIONS.useSSL,
            cleanSession: MQTT_OPTIONS.cleanSession, //实现QoS>0必须设置为false，代表不清除，是持久会话
            keepAliveInterval: MQTT_OPTIONS.keepAliveInterval,
            reconnect: MQTT_OPTIONS.reconnect, //意外断开之后会重连，第一次1秒后重连，往后每次翻倍直到2分钟，后续保持2分钟
            mqttVersion: MQTT_OPTIONS.mqttVersion,
            userName: MQTT_OPTIONS.username,
            password: MQTT_OPTIONS.password,
            onSuccess: function() {
              thant.client.onMessageArrived = function(message) {
                const data = JSON.parse(message.payloadString.replace(/\u0000*$/, ''))
                if (data != null) {
                  data.Data.forEach((item, index) => {
                    if (item.Cmd == 9) {
                      thant.indexAllData = parsingData.getNumBycommand(item.Cmd, item.Value)
                      if(thant.indexAllData.communicationState!=1){
                        thant.$modal.msgError("通讯错误");
                         clearInterval(this.realTime)
                         uni.stopPullDownRefresh()
                         uni.hideLoading({
                           noConflict:true
                         })
                         return;
                      }
                      if(thant.indexAllData.connt==false){
                          thant.$modal.msg("设备订阅已断开，请重启设备");
                          clearInterval(this.realTime)
                          uni.stopPullDownRefresh()
                          uni.hideLoading({
                            noConflict:true
                          })
                         return;
                      }
                    }
                    if (item.Cmd == 11) {
                      thant.autoCurveDataPak = parsingData.getNumBycommand(item.Cmd, item.Value)
                      let refrigerateSTime = parseInt(thant.autoCurveDataPak.refrigerateSTime)
                      let xf1STime = parseInt(thant.autoCurveDataPak.xf1STime)
                      let xf2STime = parseInt(thant.autoCurveDataPak.xf2STime)
                      let xf2ETime = parseInt(thant.autoCurveDataPak.xf2ETime)
                      if (refrigerateSTime == 0) {
                        thant.chiT = '00:00'
                      } else if (refrigerateSTime != 0 && refrigerateSTime < 10) {
                        thant.chiT = '00:0' + thant.autoCurveDataPak.refrigerateSTime.substring(0, 1)
                      } else if (refrigerateSTime >= 10 && refrigerateSTime < 60) {
                        thant.chiT = '00:' + thant.autoCurveDataPak.refrigerateSTime.substring(0, 2)
                      } else if (refrigerateSTime >= 60 && refrigerateSTime < 960) {
                        thant.chiT = '0' + thant.autoCurveDataPak.refrigerateSTime.substring(0, 1) + ":" +
                          thant.autoCurveDataPak
                          .refrigerateSTime.substring(1, 3)
                      } else {
                        thant.chiT = thant.autoCurveDataPak.refrigerateSTime.substring(0, 2) +
                          ":" + thant.autoCurveDataPak.refrigerateSTime.substring(2, 4);
                      }

                      if (xf1STime == 0) {
                        thant.prf1T = '00:00'
                      } else if (xf1STime != 0 && xf1STime < 10) {
                        thant.prf1T = '00:0' + thant.autoCurveDataPak.xf1STime.substring(0, 1)
                      } else if (xf1STime >= 10 && xf1STime < 60) {
                        thant.prf1T = '00:' + thant.autoCurveDataPak.xf1STime.substring(0, 2)
                      } else if (xf1STime >= 60 && xf1STime < 960) {
                        thant.prf1T = '0' + thant.autoCurveDataPak.xf1STime.substring(0, 1) + ":" + thant
                          .autoCurveDataPak
                          .xf1STime.substring(1, 3)
                      } else {
                        thant.prf1T = thant.autoCurveDataPak.xf1STime.substring(0, 2) +
                          ":" + thant.autoCurveDataPak.xf1STime.substring(2, 4);
                      }

                      if (xf2STime == 0) {
                        thant.prf2ST = '00:00'
                      } else if (xf2STime != 0 && xf2STime < 10) {
                        thant.prf2ST = '00:0' + thant.autoCurveDataPak.xf2STime.substring(0, 1)
                      } else if (xf2STime >= 10 && xf2STime < 60) {
                        thant.prf2ST = '00:' + thant.autoCurveDataPak.xf2STime.substring(0, 2)
                      } else if (xf2STime >= 60 && xf2STime < 960) {
                        thant.prf2ST = '0' + thant.autoCurveDataPak.xf2STime.substring(0, 1) + ":" + thant
                          .autoCurveDataPak
                          .xf2STime.substring(1, 3)
                      } else {
                        thant.prf2ST = thant.autoCurveDataPak.xf2STime.substring(0, 2) +
                          ":" + thant.autoCurveDataPak.xf2STime.substring(2, 4);
                      }

                      if (xf2ETime == 0) {
                        thant.prf2ET = '00:00'
                      } else if (xf2ETime != 0 && xf2ETime < 10) {
                        thant.prf2ET = '00:0' + thant.autoCurveDataPak.xf2ETime.substring(0, 1)
                      } else if (xf2ETime >= 10 && xf2ETime < 60) {
                        thant.prf2ET = '00:' + thant.autoCurveDataPak.xf2ETime.substring(0, 2)
                      } else if (xf2ETime > 60 && xf2ETime < 960) {
                        thant.prf2ET = '0' + thant.autoCurveDataPak.xf2ETime.substring(0, 1) + ":" + thant
                          .autoCurveDataPak
                          .xf2ETime.substring(1, 3)
                      } else {
                        thant.prf2ET = thant.autoCurveDataPak.xf2ETime.substring(0, 2) +
                          ":" + thant.autoCurveDataPak.xf2ETime.substring(2, 4);
                      }
                      thant.refrigerateSTime = thant.chiT;
                      thant.xf1STime = thant.prf1T;
                      thant.xf2STime = thant.prf2ST;
                      thant.xf2ETime = thant.prf2ET;
                    }
                    if (item.Cmd == 12) {
                      //设置温度的最大值和最小值
                      thant.setData = parsingData.getNumBycommand(item.Cmd, item.Value)
                      thant.HTp = thant.setData.freeAndStorageHighTemp
                      thant.LTp = thant.setData.freeAndStorageLowTemp
                      thant.ProHTp = thant.setData.proofHighTemp
                      thant.ProLTp = thant.setData.proofLowTemp
                    }
                    if (thant.autoCurveDataPak !== '' &&
                      thant.indexAllData !== '' &&
                      thant.setData !== '') {
                      thant.empty()
                      uni.hideLoading();
                    }
                  })
                }
              }
              thant.client.subscribe(thant.subTopic, {
                qos: 1
              });
            },
            onFailure: function(option) {
              uni.showToast({
                title: option,
                icon: "error",
              });
            }
          }
          this.client.connect(connectOptions)
        } catch (error) {
          this.$modal.msgError("连接错误");
        }
      },
      //冷藏开始时间改变时触发
      bindRefrigerateSTime: function(e) {
        this.refrigerateSTime = e.detail.value
        this.setTime(this.refrigerateSTime, 1)
      },
      //醒发1开始时间改变时触发
      bindXf1STime: function(e) {
        this.xf1STime = e.detail.value
        this.setTime(this.xf1STime, 2)
      },
      //醒发2开始时间改变时触发
      bindXf2STime: function(e) {
        this.xf2STime = e.detail.value
        this.setTime(this.xf2STime, 3)
      },
      //醒发2结束时间改变时触发
      bindXf2ETime: function(e) {
        this.xf2ETime = e.detail.value
        this.setTime(this.xf2ETime, 4)
      },
      //设置时间公共的方法
      setTime: async function(value, state) {
        //使用公共处理时间方法
        let time = value.substring(0, 2)
        let min = value.substring(3, 5)
        let oneMinSum;
        let twoMinSum;
        let thirdMinSum;
        //获取当前冷藏分钟数
        let currstorageDate = parseInt(this.refrigerateSTime.substring(0, 2) * 60) + parseInt(this.refrigerateSTime
          .substring(3, 5))
        //获取醒发1起始分钟数
        let proofingOneSDate = parseInt(this.xf1STime.substring(0, 2) * 60) + parseInt(this.xf1STime.substring(3, 5))
        //获取醒发2起始分钟数
        let proofingTwoSDate = parseInt(this.xf2STime.substring(0, 2) * 60) + parseInt(this.xf2STime.substring(3, 5))
        //获取醒发2结束分钟数
        let proofingTwoEDate = parseInt(this.xf2ETime.substring(0, 2) * 60) + parseInt(this.xf2ETime.substring(3, 5))
        //根据预约的时间判断相减的前后顺序
        if (currstorageDate > proofingOneSDate) {
          oneMinSum = (proofingOneSDate + 1440) - currstorageDate
        } else {
          oneMinSum = proofingOneSDate - currstorageDate
        }
        if (proofingOneSDate > proofingTwoSDate) {
          twoMinSum = (proofingTwoSDate + 1440) - proofingOneSDate
        } else {
          twoMinSum = proofingTwoSDate - proofingOneSDate
        }
        if (proofingTwoSDate > proofingTwoEDate) {
          thirdMinSum = (proofingTwoEDate + 1440) - proofingTwoSDate
        } else {
          thirdMinSum = proofingTwoEDate - proofingTwoSDate
        }
        //判断时间不能一致性
        const numMin = oneMinSum + twoMinSum + thirdMinSum
        if (state == 1) {
          if (currstorageDate == proofingOneSDate) {
            toast("冷藏开始时间和醒发1起始时间不能一致")
          } else {
            this.countMin(numMin, state, time, min)
          }
        } else if (state == 2) {
          if (proofingOneSDate == currstorageDate) {
            toast("醒发1起始时间和冷藏开始时间不能一致")
          } else if (proofingOneSDate == proofingTwoSDate) {
            toast("醒发1起始时间和醒发2起始时间不能一致")
          } else {
            this.countMin(numMin, state, time, min)
          }
        } else if (state == 3) {
          if (proofingTwoSDate == proofingOneSDate) {
            toast("醒发2起始时间和醒发1起始时间不能一致")
          } else if (proofingTwoSDate == proofingTwoEDate) {
            toast("醒发2起始时间和醒发2结束时间不能一致")
          } else {
            this.countMin(numMin, state, time, min)
          }
        } else {
          if (proofingTwoEDate == currstorageDate) {
            toast("醒发2结束时间和冷藏开始时间不能一致")
          } else if (proofingTwoEDate == proofingTwoSDate) {
            toast("醒发2结束时间和醒发2起始时间不能一致")
          } else {
            this.countMin(numMin, state, time, min)
          }
        }
      },
      //公共判断方法，符合要求才赋值下发
      countMin: async function(numMin, state, time, min) {
        if (1440 - numMin > 0) {
          this.loadingClick()
          if (state == 1) {
            this.autoCurveDataPak.refrigerateSTime = (time + min)
          } else if (state == 2) {
            this.autoCurveDataPak.xf1STime = (time + min)
          } else if (state == 3) {
            this.autoCurveDataPak.xf2STime = (time + min)
          } else {
            this.autoCurveDataPak.xf2ETime = (time + min)
          }
          const success = await getPrefixAndControl.controlCmd(this.equipmentTypeId, this.equipmentNo, CmdType
            .AutoCurve, this.getAutoCurveArray())
          if (success.code != 200) {
            this.$modal.msgError("下发失败");
          }
        } else {
          toast('冷藏->醒发1->醒发2的预约时间总和不能超过24小时,请重新设置时间');
        }
      },
      //点击tab切换内容
      navSwitch(index) {
        this.show = false
        this.etimeShow = false
        if (index == 0) {
          this.parameterData[0].imgurl = 'https://mkservice.mk-iot.com/subFile/mk2240/freezing_click.png',
            this.parameterData[1].imgurl = 'https://mkservice.mk-iot.com/subFile/mk2240/refrigerate_onclick.png',
            this.parameterData[2].imgurl = 'https://mkservice.mk-iot.com/subFile/mk2240/proofingone_onclick.png',
            this.parameterData[3].imgurl = 'https://mkservice.mk-iot.com/subFile/mk2240/proofingtwo_onclick.png'
        } else if (index == 1) {
          this.parameterData[0].imgurl = 'https://mkservice.mk-iot.com/subFile/mk2240/freezing_onclick.png',
            this.parameterData[1].imgurl = 'https://mkservice.mk-iot.com/subFile/mk2240/refrigerate_click.png',
            this.parameterData[2].imgurl = 'https://mkservice.mk-iot.com/subFile/mk2240/proofingone_onclick.png',
            this.parameterData[3].imgurl = 'https://mkservice.mk-iot.com/subFile/mk2240/proofingtwo_onclick.png'
        } else if (index == 2) {
          this.parameterData[0].imgurl = 'https://mkservice.mk-iot.com/subFile/mk2240/freezing_onclick.png',
            this.parameterData[1].imgurl = 'https://mkservice.mk-iot.com/subFile/mk2240/refrigerate_onclick.png',
            this.parameterData[2].imgurl = 'https://mkservice.mk-iot.com/subFile/mk2240/proofingone_click.png',
            this.parameterData[3].imgurl = 'https://mkservice.mk-iot.com/subFile/mk2240/proofingtwo_onclick.png'
        } else if (index == 3) {
          this.parameterData[0].imgurl = 'https://mkservice.mk-iot.com/subFile/mk2240/freezing_onclick.png',
            this.parameterData[1].imgurl = 'https://mkservice.mk-iot.com/subFile/mk2240/refrigerate_onclick.png',
            this.parameterData[2].imgurl = 'https://mkservice.mk-iot.com/subFile/mk2240/proofingone_onclick.png',
            this.parameterData[3].imgurl = 'https://mkservice.mk-iot.com/subFile/mk2240/proofingtwo_click.png'
        }
        this.navState = index
      },
      //下发102温度、湿度，预约时间公共方法
      getAutoCurveArray: function() {
        let autoCurveState = {
          ChiT: parseInt(this.autoCurveDataPak.refrigerateSTime, 16),
          Prf1T: parseInt(this.autoCurveDataPak.xf1STime, 16),
          Prf2ST: parseInt(this.autoCurveDataPak.xf2STime, 16),
          Prf2ET: parseInt(this.autoCurveDataPak.xf2ETime, 16),
          FreTp: this.autoCurveDataPak.freeTemp,
          ChiTp: this.autoCurveDataPak.storageTemp,
          Prf1Tp: this.autoCurveDataPak.xf1Temp,
          Prf2Tp: this.autoCurveDataPak.xf2Temp,
          Prf1Hm: this.autoCurveDataPak.xf1Humidity,
          Prf2Hm: this.autoCurveDataPak.xf2Humidity
        }
        return autoCurveState;
      },
      loadingClick() {
        const thant = this
        thant.leeLoading.show = true
        thant.timeout = setTimeout(function() {
          thant.leeLoading.show = false
          thant.$modal.msgError("操作未成功");
        }, 5000);
      },
      //清除
      empty(){
        clearInterval(this.realTime)
        clearTimeout(this.timeout)
        this.leeLoading.show=false
        uni.stopPullDownRefresh()
      }
    },
    onUnload() {
      clearInterval(this.realTime)
      clearTimeout(this.timers)
      if (this.client != null) {
        this.client.disconnect();
        this.client = null;
      }
    },
    //下拉刷新
    onPullDownRefresh() {
      this.indexAllData = ''
      this.autoCurveDataPak = ''
      this.setData = ''
      clearInterval(this.realTime)
      clearTimeout(this.timers)
      this.$modal.loading("数据加载中...");
      this.getIndexData()
    }
  }
</script>

<style>
  page {
    background-color: #f6f6f6;
  }

  .header_title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 150rpx;
  }

  .automatic {
    font-size: 48rpx;
    font-weight: bold;
    margin-left: 36rpx;
  }

  .parameter_title {
    margin-left: 19rpx;
    font-weight: bold;
    font-size: 28rpx;
  }

  .parameter_seting {
    margin-top: 12rpx;
    background-color: #fff;
  }

  .parameter_name {
    display: flex;
    align-items: center;
    padding-top: 40rpx;
  }

  .rectangleimg {
    width: 12rpx;
    height: 30rpx;
    margin-left: 32rpx;
  }

  .control_btn {
    background-color: #f0f0f0;
    width: 688rpx;
    height: 130rpx;
    border-radius: 65rpx;
    margin-top: 30rpx;
    margin: 30rpx auto 30rpx auto;
    display: flex;
  }

  .tabs {
    width: 172rpx;
    height: 130rpx;
    background-color: #f0f0f0;
    border-radius: 65rpx;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  .tab_img {
    width: 50rpx;
    height: 50rpx;
  }

  .freezing_text {
    font-size: 28rpx;
    margin-top: 10rpx;
  }

  .selectTime {
    display: flex;
    justify-content: space-between;
    width: 80%;
    margin: 40rpx auto;
  }

  .start_time {
    display: flex;
    font-size: 32rpx;
    align-items: center;
  }

  .start_time>image {
    width: 42rpx;
    height: 42rpx;
  }

  .temp_set {
    display: flex;
    align-items: center;
    margin-top: 50rpx
  }

  .start_endtime {
    font-size: 44rpx;
    font-weight: 500;
    display: flex;
    width: 80%;
    margin: 30rpx auto;
    justify-content: space-between;
  }

  .tempclass {
    width: 95%;
    margin: 20rpx auto;
  }

  .popupClass {
    font-size: 44rpx;
    font-weight: 500;
  }

  .startTimetext {
    margin-left: 20rpx;
  }

  .uni-input {
    font-size: 44rpx;
  }
</style>